/**
 * @file   DataBusServer.h
 * @author Djuro Drljaca (djurodrljaca@gmail.com)
 * @date   2013-05-03
 * @brief  DataBus Server.
 *
 * Copyright (C) 2013  Djuro Drljaca <djurodrljaca@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef DATABUSSERVER_H
#define DATABUSSERVER_H

#include "DataBusClientListModel.h"
#include <DataBus/Server/Server.h>
#include <QtCore/QObject>

class DataBusServer : public DataBus::Server
{
    Q_OBJECT

public:
    /**
     * @brief DataBus Server construcotr
     *
     * @param parent    Parent object
     */
    explicit DataBusServer(QObject *parent = 0);

    /**
     * @brief DataBus Server destructor
     */
    ~DataBusServer();

    /**
     * @brief Returns pointer to Client List Model
     *
     * @return Pointer to Client List Model
     */
    DataBusClientListModel * getClientListModel();

    /**
     * @brief Removes all Clients from the list
     */
    void removeAllClients();

    /**
     * @brief Remove Client from the list
     *
     * @param index Client's index in the list
     *
     * @retval true     Success
     * @retval false    Error
     */
    bool removeClient(const int index);

    /**
     * @brief Tries to register the client
     *
     * @param client    Client that requested to be registered
     * @param packet    Register Client Request packet
     *
     * @retval RETURN_STATUS_SUCCESS            Success
     * @retval RETURN_STATUS_INVALID_CLIENT_ID  Error
     */
    quint8 registerClient(const DataBus::Client *client, const DataBus::Packet &packet);

private:
    /**
     * @brief Client List Model
     */
    DataBusClientListModel m_clientListModel;
};

#endif // DATABUSSERVER_H
